from volcenginesdkarkruntime import Ark

client = Ark(
    api_key="780242c1-b80a-43d1-b5a1-fcc5bea20248",
    base_url="https://ark.cn-beijing.volces.com/api/v3"
)


def generate_vue_component(prompt):
    response = client.chat.completions.create(
        model="deepseek-r1-250120",
        messages=[
            {"role": "system", "content": """你是一个全栈的架构师"""},
            {"role": "user", "content": prompt}
        ],
        stream=True
    )

    full_content = []
    for chunk in response:
        if chunk.choices:
            content = chunk.choices[0].delta.content
            if content:
                full_content.append(content)

    return "".join(full_content)
prompt="""
当前文件夹下有个data.json文件，取出来遍历这个json，如下所示：
[
 {
    "path": "/bms",
    "component": "views/common/content",
    "name": "bms",
    "meta": {
      "title": "物业管理",
      "icon": "fa-building",
      "htmlUrl": "views/common/content.html"
    },
    "children": [
      {
        "path": "/resource",
        "component": "common/content",
        "name": "resource",
        "meta": {
          "title": "资源管理",
          "icon": "fa-share-alt",
          "htmlUrl": "bms/views/common/content.html"
        },
        "children": [
          {
            "path": "/resourceSysCategoryTree",
            "component": "views/dataClassification/resourceSysCategoryTree",
            "name": "resourceDataClassificationSysCategoryTree",
            "meta": {
              "title": "资源分类",
              "icon": "el-icon-menu",
              "htmlUrl": "views/dataClassification/resourceSysCategoryTree.html",
              "fileJs": [
                "js/dataClassification/resourceDataClassControllers.js"
              ]
            }
          },
          {
            "path": "/Engineering",
            "component": "resource/resourceBasicInfo/EngineeringResourceList",
            "name": "resourceEngineering",
            "meta": {
              "title": "工程资源管理",
              "icon": "el-icon-menu",
              "htmlUrl": "bms/views/resource/resourceBasicInfo/EngineeringResourceList.html",
              "fileJs": [
                "bms/js/resource/EngresourceBasicInfoControllers.js"
              ],
              "subPages": [
                {
                  "title": "工程生成二维码",
                  "path": "/engineeringResourceQRCodes",
                  "icon": "el-icon-menu",
                  "htmlUrl": "bms/views/resource/resourceBasicInfo/engineeringResourceQRCodes.html",
                  "alias": "system.resource_engineeringResourceQRCodes",
                  "fileJs": [
                    "bms/js/resource/EngresourceBasicInfoControllers.js"
                  ]
                },
                {
                  "title": "工程资源明细",
                  "path": "/get",
                  "icon": "el-icon-menu",
                  "htmlUrl": "bms/views/resource/resourceBasicInfo/EngineeringResourceGet.html",
                  "alias": "system.resource_getEngineering",
                  "fileJs": [
                    "bms/js/resource/EngresourceBasicInfoControllers.js"
                  ]
                },
                {
                  "title": "工程资源添加",
                  "path": "/add",
                  "icon": "el-icon-menu",
                  "htmlUrl": "bms/views/resource/resourceBasicInfo/EngineeringResourceEdit.html",
                  "alias": "system.resource_addEngineering",
                  "fileJs": [
                    "bms/js/resource/EngresourceBasicInfoControllers.js"
                  ]
                }
              ]
            }
          },
          
          以上为json片断，现在我的需求是，通过遍历每一项的时候，找到id=192916780820461719项，并且拿到htmlUrl，如："htmlUrl": "views/dataClassification/resourceSysCategoryTree.html"
          然后通过python拼接成完整的地址是：/Users/justinzhang/WorkSpace/com.ein/project/南京/angularjs/platform-ui/html/views/dataClassification/resourceSysCategoryTree.html
          
          以及和fileJs中的url，如：js/dataClassification/resourceDataClassControllers.js，
          完整的地址是：/Users/justinzhang/WorkSpace/com.ein/project/南京/angularjs/platform-ui/html/js/dataClassification/resourceDataClassControllers.js
          
          然后使用python找到这两个文件，注意：找到html文件中的ng-controller="customerInfoEditCtrl"或者data-ng-controller="customerInfoEditCtrl"然后在这个js文件中找到这个customerInfoEditCtrl方法代码，
          
          如：
          function customerInfoEditCtrl($scope, $compile, baseService, dialogService, $sessionStorage, $rootScope, $http, dataDictService) {
           ...
          }
          注意包含customerInfoEditCtrl方法完整的方法体，而不只是一行代码，如果未找到customerInfoEditCtrl这个方法，帮我打印下是在哪个js文件中没找到的，方便我调试
          
          并把它们组建成一个新的文件(没有就新建，有则替换)，地址是component里面的值，如"component": "views/dataClassification/resourceSysCategoryTree",
          那么完整的文件地址是：/Users/justinzhang/WorkSpace/com.ein/demo/angularjs2vue3/RuoYi-Vue/ruoyi-ui/src/views/dataClassification/resourceSysCategoryTree.vue
          
          还有
          
          如果js代码中有这样的代码：
          dialogService.page("system.addCustomerInfo", {
            area: ['40vw', '50vh'],
            btn: ["确认", "取消"],
            title: title,
            alwaysClose: false,
            pageParam: pageParam
          })
          
          我们到该菜单项的meta.subPages属性，筛选出alias=system.addCustomerInfo的项，
          
          然后，
          
          拿到里面的htmlUrl属性值：bms/views/resource/resourceBasicInfo/engineeringResourceQRCodes.html
          拼接成完整的路径：/Users/justinzhang/WorkSpace/com.ein/project/南京/angularjs/platform-ui/html/bms/views/resource/resourceBasicInfo/engineeringResourceQRCodes.html
          
          以及和fileJs中的url，如："bms/js/resource/EngresourceBasicInfoControllers.js"，
          拼接成完整的路径：/Users/justinzhang/WorkSpace/com.ein/project/南京/angularjs/platform-ui/html/bms/js/resource/EngresourceBasicInfoControllers.js
          
          然后使用python找到这两个文件，注意：找到html文件中的ng-controller="customerInfoEditCtrl"或data-ng-controller="customerInfoEditCtrl"然后在这个js文件中找到这个customerInfoEditCtrl方法代码，如下所示：
          
          function customerInfoEditCtrl($scope, $compile, baseService, dialogService, $sessionStorage, $rootScope, $http, dataDictService) {
           ...
          }
                    
         注意包含customerInfoEditCtrl方法完整的方法体，而不只是一行代码，如果未找到customerInfoEditCtrl这个方法，帮我打印下是在哪个js文件中没找到的，方便我调试

          
          并把它们组建成一个新的文件(没有就新建，有则替换)，新的文件放在上面新建文件的位置下再新建一个dlg文件夹，文件名是engineeringResourceQRCodes.html里面的文件名是engineeringResourceQRCodes.vue，
          也就是./dlg/engineeringResourceQRCodes.vue
          
          上面操作使用ast实现是不是简单点
          
          帮我生成一个这样的python代码
"""
code = generate_vue_component(prompt)
print("结果：\n")
print(code)
# ，并且templateUrl地址，对应的是当前目录下的html的地址，我们按照这个一级菜单和二级菜单新建文件夹和文件，文件夹名称就是alias中的值，如："alias": "system.resource_Engineering",那么文件夹名就是：resourceEngineering，文件名称就是这个文件名，如：'a/b/c.html'，那么组件就是c.vue，path='system/resourceEngineering'注意，我们在/Users/justinzhang/WorkSpace/com.ein/demo/angularjs2vue3/RuoYi-Vue/ruoyi-ui/src/views中新建文件夹和文件，
